package P2000;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author: zhouyang
 * @descrpition:
 * @time: 2019-10-11 17:14
 */
public class P2089_烤鸡 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.close();
        if(n < 10 || n > 30) System.out.println(0);
        else{
            invoke(n);
        }
    }

    private static List<String> res = new ArrayList<>();

    private static void invoke(int n) {
        int[] nums = new int[10];
        dfs(0,n,nums);
        if(res.size() == 0){
            System.out.println(res.size());
        }else{
            System.out.println(res.size());
            for(int i=0;i<res.size();++i){
                System.out.println(res.get(i));
            }
        }
    }

    private static void dfs(int index, int sum, int[] nums) {
        for(int i=1;i<=3;++i){
            if(sum-i < 0){
                return ;
            }
            nums[index] = i;
            if(index == 9){
                if(sum-i == 0){
                    res.add(String.format("%d %d %d %d %d %d %d %d %d %d",nums[0],nums[1],nums[2],nums[3],nums[4],nums[5],nums[6],nums[7],nums[8],nums[9]));
                }
                continue;
            }
            dfs(index+1,sum-i,nums);
        }
    }

}
